package com.chenfan.process.entity.vo;

import java.util.List;

import org.springframework.util.CollectionUtils;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author K
 * @date 2021/3/9 执行过程
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProcessDetailActiveVO {

    @ApiModelProperty("审批是否完成")
    private Boolean finish;

    @ApiModelProperty("是否显示 通过/拒绝按钮")
    private Boolean showButton;

    @ApiModelProperty("是否有拒绝")
    private Boolean refuse;

    @ApiModelProperty("审批人员名称")
    private String approvalUserName;

    @ApiModelProperty("必传参数检查")
    private String checkParam;

    @ApiModelProperty("编辑字段检查")
    private String editableParam;

    public Boolean getFinish() {
        if (Boolean.TRUE.equals(finish)) {
            return Boolean.TRUE;
        }
        return !CollectionUtils.isEmpty(processList) && processList.stream().noneMatch(ProcessDetailItem::getActive)
            && !refuse;
    }

    @ApiModelProperty("节点列表")
    private List<ProcessDetailItem> processList;

    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    @Data
    public static class ProcessDetailItem {

        @ApiModelProperty("主键ID")
        private Long id;

        @ApiModelProperty("激活")
        private Boolean active;
    }
}
